package com.stylefeng.guns.rest.modular.message.service;

import com.stylefeng.guns.rest.common.persistence.dao.JubaoMapper;
import com.stylefeng.guns.rest.common.persistence.dao.MessageMapper;
import com.stylefeng.guns.rest.common.persistence.model.Jubao;
import com.stylefeng.guns.rest.common.persistence.model.Message;
import com.stylefeng.guns.rest.modular.attent.controller.dto.AttentHotRequest;
import com.stylefeng.guns.rest.modular.jubao.controller.dto.JubaoRequest;
import com.stylefeng.guns.rest.modular.message.controller.dto.MessageEntity;
import org.apache.commons.collections.map.HashedMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * Created by ASUS-PC on 2018/6/26.
 */
@Service
public class MessageService {
    @Autowired
    MessageMapper messageMapper;


    public int inserData(Message message){
        return messageMapper.insert(message)>0?1:0;
    }

    public List<MessageEntity> getMessageList(AttentHotRequest request){
        Map<String ,Object> data = new HashedMap();
        data.put("userId",request.getUserId());
        data.put("pageIndex",(request.getPage()-1)*request.getSize());
        data.put("pageSize",request.getSize());
        return messageMapper.getMessageList(data);
    }
}
